
import { defineStore } from 'pinia'
import { getAdminToken, setAdminToken } from '@/addon/htscrm/utils/storage';
interface IConfig {
  is_login: boolean;
  token: string;
  userInfo: any
}
const useAdminStore = defineStore('admin', {
    state: (): IConfig => {
        return {
          is_login: false,
          token: getAdminToken() || '',
          userInfo: uni.getStorageSync('wap_admin_user_info') || {}
        }
    },
    actions: {
      setUserInfo(value: IUserInfo) {
        this.userInfo = value
        uni.setStorageSync('wap_admin_user_info', value)
      },

      getUserInfo() {
        return this.userInfo
      },
      getAdminToken() {
        return this.token
      },
      setAdminToken(token: string) {
        this.token = token
        setAdminToken(token)
      }
    }
})

export default useAdminStore
